package com.xnyzc.lhy.didi.mapper.other;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xnyzc.lhy.order.entity.user.OaDUserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-18
 */
public interface OaDUserInfoMapper extends BaseMapper<OaDUserInfo> {

    @Select("SELECT " +
            "oa_d_user.driver_id AS driverId," +
            "oa_d_user.driver_name AS driverName," +
            "oa_d_user.driver_phone AS driverPhone," +
            " oa_d_user_info.total_service_score AS serviceScore," +
            "oa_d_driver_vehicle.vehicle_id AS vehId," +
            "oa_sys_vehicle.veh_no AS vehNo," +
            "oa_sys_vehicle_mdict.expand3 AS vehType," +
            "oa_sys_vehicle_mdict.name AS vehicleBrandDetail," +
            "re.cname AS vehicleBrand,   " +
            " oa_sys_dict.label AS vehColor " +
            "FROM oa_d_user " +
            "LEFT JOIN oa_d_user_info " +
            "ON oa_d_user.driver_id=oa_d_user_info.driver_id " +
            "LEFT JOIN oa_d_driver_vehicle " +
            "ON oa_d_user.driver_id=oa_d_driver_vehicle.driver_id " +
            "LEFT JOIN oa_sys_vehicle " +
            "ON oa_d_driver_vehicle.vehicle_id=oa_sys_vehicle.vehicle_id " +
            "LEFT JOIN oa_sys_vehicle_mdict " +
            "ON oa_sys_vehicle.code=oa_sys_vehicle_mdict.code " +
            "LEFT JOIN ( SELECT DISTINCT a.parent_id AS apid,c.NAME AS cname FROM oa_sys_vehicle_mdict a "+
                            "LEFT JOIN oa_sys_vehicle_mdict b ON a.parent_id = b.mdict_id "+
                            "LEFT JOIN oa_sys_vehicle_mdict c ON b.parent_id = c.mdict_id "+
                            "WHERE c.expand1=1 "+
						")re ON re.apid=oa_sys_vehicle_mdict.parent_id "+
            "LEFT JOIN oa_sys_dict " +
            "ON oa_sys_vehicle.veh_color=oa_sys_dict.value " +
            "WHERE oa_sys_dict.type='vegicle_color_type' and oa_d_user.driver_id=${driverId}")
    Map<String, Object> getDriverInfo(@Param("driverId") String driverId);

}
